package com.blinddate.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blinddate.pojo.entity.UserInf;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserInfMapper extends BaseMapper<UserInf> {
    @Select("SELECT id,name,age,education,height,place,income,\n" +
            "self_intro,select_age,select_education,\n" +
            "select_height,phone,gender,habitation,\n" +
            "home,career,school,real_estate,vehicle,\n" +
            "nation,shape,marriage,marry,user_id,img_src,\n" +
            "code_src,head_src FROM `user_inf`  WHERE user_id NOT IN ( SELECT get_id FROM interest WHERE user_id = #{userId}) AND gender != #{value} AND IF( #{value} = 1,age<=#{age}+5,age >= #{age}-5) AND place = #{place}  ORDER BY RAND(#{rand}) LIMIT #{count};")
    public List<UserInf> getList(@Param("value") Integer gender,@Param("rand") String rand,@Param("count") Integer count,@Param("place") String place,@Param("userId") Long userId,@Param("age") Integer age);

    @Select("SELECT gender FROM user_inf WHERE user_id = #{value}")
    public Integer getGender(@Param("value") Long userId);


    @Select("SELECT id,name,age,education,height,place,income,\n" +
            "self_intro,select_age,select_education,\n" +
            "select_height,phone,gender,habitation,\n" +
            "home,career,school,real_estate,vehicle,\n" +
            "nation,shape,marriage,marry,user_id,img_src,\n" +
            "code_src,head_src FROM `user_inf`  WHERE user_id NOT IN ( SELECT get_id FROM interest WHERE user_id = #{userId}) AND place like CONCAT('%',#{market},'%') AND  gender != #{value} AND IF( #{value} = 1,age<=#{age}+5,age >= #{age}-5) AND place != #{place} ORDER BY RAND(#{rand}) LIMIT #{count};")
    public List<UserInf> getOtherList(@Param("value") Integer gender,@Param("rand") String rand,@Param("count") Integer count,@Param("place") String place,@Param("market") String market,@Param("userId") Long userId,@Param("age") Integer age);




}
